package org.fuys.coder.domain.audit.model.res;

import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;
import org.fuys.coder.domain.audit.model.vo.AuditResultLabels;
import org.fuys.coder.domain.audit.model.vo.AuditResultTypeVO;

/**
 * @projectName: fuys-low-coder
 * @package: org.fuys.coder.domain.audit.model.res
 * @className: AuditResult
 * @author: WangJing
 * @description: 审核结果
 * @date: 2024/6/22 16:20
 * @version: 1.0
 */
@Data
@AllArgsConstructor
@NoArgsConstructor
public class AuditResult {
    private int type;
    private String msg;
    private boolean finish;
    //任务id 方便之后的匹配
    private String taskId;
    public static AuditResult normal(String ...id){
        return new AuditResult(AuditResultTypeVO.PASS.getIndex()
                , AuditResultLabels.NORMAL.getDesc(),true,id.length==0?null:id[0]);
    }

    public static AuditResult abnormal(int type,String labels,String ...id){
        final String[] split = labels.split(",");
        StringBuilder stringBuilder=new StringBuilder();
        for (String s : split) {
            stringBuilder.append(AuditResultLabels.getDesc(s));
            stringBuilder.append(",");
        }
        final String msg= stringBuilder.toString();
        stringBuilder.deleteCharAt(msg.length()-1);
        return new AuditResult(type,msg,true,id.length==0?null:id[0]);
    }

}
